<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>

    <script>

      

        function Dog (color) {
            this.color = color ;
            this.type = '狗子' ;
            this.say = '汪' ;
        }

        Dog.prototype.speak = function() {
            console.log('hello world');
        }

        Dog.prototype.hehe = function() {
            console.log('hello world');
        }


        function KeJi(name , age , color) {
            this.name = name ;
            this.age = age ;

            // 想调用Dog的属性和方法
            // this.type = '狗子' ;
            // this.say = '汪' ;

        }

        // 浅复制
        // KeJi.prototype = Dog.prototype ;

        // KeJi.prototype.a = 1 ;
        // console.log(Dog.prototype);

       
        // KeJi.prototype = {...Dog.prototype} ;


        for(let key in Dog.prototype) {
            KeJi.prototype[key] = Dog.prototype[key] ;
        }


        const k = new KeJi('') ;

        console.log(k);



    </script>
    
</body>
</html>